{% extends "header.html"%}
{% block content%}

<script type="text/javascript">
function checkPassword(){
	var pass = $("#password").val();
	var pass_rep = $("#password_rep").val();
	var old_pass = $("#oldpass").val();
	if(pass.length < 6 || pass.length > 16){//old_pass=="" || pass=="" ||
		alert("你输入的密码过短或过长,请重新输入");
		return false;
	}

	if (!pass.match(/[A-Z]/)){
        alert("密码必须包含大写字母！,请重新输入");
        return false;
	}

    if (!pass.match(/[a-z]/)){
        alert("密码必须包含小写字母！,请重新输入");
        return false;
    }

	if (!pass.match(/[0-9]/)){
		alert("密码必须包含数字！");
		return false;
	}

	if (!pass.match(/[\@\#\$\%\!\&\*]/)){
		alert("密码必须至少包含!,@,#,$,%,&,*中的一个！");
		return false;
	}

	if(pass != pass_rep){
		alert("两次输入的密码不相等");
		return false;
	}
	return true;
}

</script>

{% if newPass %}
    <div class="alert alert-info">{{op_msg}}<font color="red">{{newPass}}</font></div>
{% else %}
    <form class="well form-horizontal" id="changepass" name="changepass" action="" method="post">
    <fieldset><legend>修改密码</legend>
       <div class="control-group">
          <label class="control-label"  for="username">用户名</label>
          <div class="controls">
          <input type="text" class="input-xxlarge" id="username" name="username" value="{{request.session.username}}" readonly></input>
          </div>
        </div>
       <div class="control-group">
          <label class="control-label" for="oldpass">原始密码</label>
          <div class="controls">
           <input type="password" class="input-xxlarge" id="oldpass" name="oldpass"></input>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="password">新密码</label>
          <div class="controls">
           <input type="password" class="input-xxlarge" id="password" name="password"></input>&nbsp;&nbsp;
           新密码长度须在6到32位之间，且必须包含大小写字母、数字以及至少包含!,@,#,$,%,&,*中的一个
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="password_rep">再次输入密码</label>
          <div class="controls">
           <input type="password" class="input-xxlarge" id="password_rep" name="password_rep"></input>
          </div>
        </div>
        <div class="form-actions">
        <button type="submit" class="btn btn-info" onclick="return checkPassword()">确定</button>
        <button type="reset" class="btn">取消</button>
        </div>
    </fieldset>
    </form>
{% endif %}
{% endblock %}